from numpy import *
from scipy.special import j0
from time import time

def J(n, m):
    return j0(cos(n+m))

n = 5000
ind = arange(n)
xx,yy = meshgrid(ind, ind)
'''
t1 = time()
res = J(xx, yy)
print res   
t2 = time()
print t2 - t1
'''
t1 = time()
res = fromfunction(J,(n-1,n-1))
print res   
t2 = time()
print t2 - t1


